﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;
using Common.Linq;
using Database.infrastructure;
using MyBlogs.Areas.Article.Models;

namespace MyBlogs.Areas.Article.Controllers
{
    public class ArticlesController : Controller
    {
        private readonly IRepositoryBase<Database.Model.Article> _iArticleService;

        private readonly IUnitOfWork _iUinOfWork;

        public ArticlesController(IRepositoryBase<Database.Model.Article> iArticleService, IUnitOfWork iUinOfWork)
        {
            _iArticleService = iArticleService;
            _iUinOfWork = iUinOfWork;
        }

        // GET: Article/ArticleList
        public ActionResult ArticleList(int pageIndex = 1)
        {
            var list = _iArticleService.GetAll(a => a.IsDelete == false).Search(Request.QueryString).OrderBy(a => a.Id).ToPagedList(pageIndex).Translat(new ArticlePageModel());

            return View(list);
        }
    }
}